package practice;
import java.util.Arrays;
public class Day06_12 {
    public static void main(String[] args) {
        //第一题 求最大数值并扩容填充
        int[] arr1 = new int[10];
        System.out.println("最初：");
        for (int i=0;i<arr1.length;i++) {
            arr1[i] = (int)(Math.random()*100);
            System.out.print(arr1[i]+"\t");
        }
        int _max = arr1[0];
        for (int i=1;i<arr1.length;i++) {
            if (arr1[i]>_max) {
                _max = arr1[i];
            }
        }
        System.out.println("数组的最大值为："+_max);
        arr1 = Arrays.copyOf(arr1,arr1.length+1);
        arr1[arr1.length-1] = _max;
        System.out.println("扩容后数组：");
        for (int i=0;i<arr1.length;i++) {
            System.out.print(arr1[i]+"\t");
        }
        System.out.println();

        //第二题 方法的练习 参数
        say();

        sayHi("许鑫泽");

        sayHello("张三",25);

        //第三题 方法的练习 返回值
        double a = getNum();
        System.out.println(a);

        int sum1 = plus(10,15);
        System.out.println(sum1);
        int a1 = (int)(Math.random()*100);
        int a2 = (int)(Math.random()*100);
        int add1 = plus(a1,a2);
        System.out.println(a1+"+"+a2+"="+add1);

        int[] _arr1 = testArray(10,20);
        for (int i=0;i<_arr1.length;i++) {
            System.out.print(_arr1[i]+"\t");
        }
        System.out.println("数组的长度为："+_arr1.length);
        int[] arr2 = testArray(15,50);
        for (int i=0;i<arr2.length;i++) {
            System.out.print(arr2[i]+"\t");
        }
        System.out.println("数组的第一个元素为："+arr2[0]);

    }
    public static void say() {
        System.out.println("hello,大家好。");
    }
    public static void sayHi(String name) {
        System.out.println("hello,我叫："+name);
    }
    public static void sayHello(String name,int age) {
        System.out.println("大家好，我叫"+name+",今年"+age+"岁了。");
    }
    public static double getNum() {
        return 10.11;
    }
    public static int plus(int m1,int m2) {
        m1 = (int)(Math.random()*100);
        m2 = (int)(Math.random()*100);
        int sum = m1+m2;
        return sum;
    }
    public static int[] testArray(int length1, int max) {
        int[] arr1 = new int[length1];
        for (int i=0;i<arr1.length;i++) {
            arr1[i] = (int)(Math.random()*max);
        }
        return arr1;
    }
}
